﻿using System;
using System.Web.Mvc;

namespace KLS.PPDS.Web.Controllers.Article
{
    public class PdfActionResult : ActionResult
    {
        public PdfActionResult() { }
        public byte[] PdfStream { get; set; }
        public override void ExecuteResult(ControllerContext context)
        {
            if (PdfStream == null)
            {
                throw new ArgumentNullException("PDF");
            }

            context.HttpContext.Response.Clear();
            context.HttpContext.Response.ContentType = "application/pdf";
            context.HttpContext.Response.OutputStream.Write(PdfStream, 0, PdfStream.Length);
            context.HttpContext.Response.Flush();
            try { context.HttpContext.Response.End(); }
            catch { }

        }       

    }
}